package com.ysqcould.allocation.service.impl;


import com.ysqcould.allocation.domain.Flow;
import com.ysqcould.allocation.mapper.FlowMapper;
import com.ysqcould.allocation.service.IFlowService;
import com.ysqcould.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 流程Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-06-29
 */
@Service
public class FlowServiceImpl implements IFlowService
{
    @Autowired
    private FlowMapper flowMapper;

    /**
     * 查询流程
     * 
     * @param id 流程主键
     * @return 流程
     */
    @Override
    public Flow selectFlowById(Long id)
    {
        return flowMapper.selectFlowById(id);
    }

    /**
     * 查询流程列表
     * 
     * @param flow 流程
     * @return 流程
     */
    @Override
    public List<Flow> selectFlowList(Flow flow)
    {
        return flowMapper.selectFlowList(flow);
    }

    /**
     * 新增流程
     * 
     * @param flow 流程
     * @return 结果
     */
    @Override
    public int insertFlow(Flow flow)
    {
        flow.setCreateTime(DateUtils.getNowDate());
        return flowMapper.insertFlow(flow);
    }

    /**
     * 修改流程
     * 
     * @param flow 流程
     * @return 结果
     */
    @Override
    public int updateFlow(Flow flow)
    {
        flow.setUpdateTime(DateUtils.getNowDate());
        return flowMapper.updateFlow(flow);
    }

    /**
     * 批量删除流程
     * 
     * @param ids 需要删除的流程主键
     * @return 结果
     */
    @Override
    public int deleteFlowByIds(Long[] ids)
    {
        return flowMapper.deleteFlowByIds(ids);
    }

    /**
     * 删除流程信息
     * 
     * @param id 流程主键
     * @return 结果
     */
    @Override
    public int deleteFlowById(Long id)
    {
        return flowMapper.deleteFlowById(id);
    }

    @Override
    public int updateStatus(Flow flow) {
        Flow flowById = flowMapper.selectFlowById(flow.getId());
        flowById.setStatus(flow.getStatus());
        return flowMapper.updateFlow(flowById);
    }
}
